package com.zhou.matc

/*
 * @Description: 
 * @Author: ZhOu 
 * @Date: 2018/6/13
 */
object MatchClassDemo {

  case class Person(id: Int, name: String)

  def main(args: Array[String]): Unit = {
    val tom = new Person(1, "Tom")
    val jack = new Person(2, "Jack")
    val lucy = new Person(3, "Lucy")

    for (person <- List(tom, jack, lucy)) {
      person match {
        case Person(1, "Tom") => println("hi,Tom")
        case Person(2, "Jack") => println("hi,Jack")
        case Person(id, name) => println(id + "=" + name)
      }
    }
  }

}
